{{- define "image_pull_secret" }}
{{- printf "{\"auths\": {\"%s\": {\"username\": \"%s\",\"password\": \"%s\", \"auth\": \"%s\"}}}" .Values.image_registry.addr .Values.image_registry.user .Values.image_registry.passwd (printf "%s:%s" .Values.image_registry.user .Values.image_registry.passwd | b64enc) | b64enc }}
{{- end }}


{{- define "etcdUrlJoinListWithComma" -}}
{{- $local := dict "first" true -}}
{{- $etcd_peer_port := .Values.etcd.peer_port -}}
{{- range $k, $v := .Values.etcd_hosts -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}=http://{{- $v -}}:{{ $etcd_peer_port }}{{- $_ := set $local "first" false -}}{{- end -}}
{{- end -}}

{{- define "replicas.etcd" }}
{{- if eq .Values.replica_semantic "ha" -}}
{{- print .Values.ha_replicas.etcd }}
{{- else if eq .Values.replica_semantic "poc" -}}
{{- print .Values.poc_replicas.etcd }}
{{- end -}}
{{- end }}

